﻿using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using ProtoBuf.Grpc;
using ProtoBuf.Grpc.Server;
using Shared;

var builder = WebApplication.CreateBuilder(args);
builder.WebHost.ConfigureKestrel(o => { o.ListenAnyIP(5001, options =>
{
    options.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http2;
}); });
builder.Services.AddGrpc();
builder.Services.AddCodeFirstGrpc();

var app = builder.Build();
app.MapGrpcService<OrderService>();

app.Run();
return;


internal class OrderService : IOrderService
{
    //可空类型不在需要包装
    public Task<CreateOrderResp> CreateOrderAsync(CreateOrderReq req, CallContext context = default)
    {
        return Task.FromResult(new CreateOrderResp { Success = true, OrderId = null });
    }
}